# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=qt6-quick3dphysics
_qtver=6.6.0
pkgver=${_qtver/-/}
pkgrel=1
arch=(loong64 x86_64)
url='https://www.qt.io'
license=(GPL3 LGPL3 FDL custom)
pkgdesc='Physics engine integration for Qt Quick 3D'
depends=(gcc-libs
         glibc
         qt6-base
         qt6-declarative
         qt6-quick3d)
makedepends=(cmake
             ninja
             qt6-shadertools)
groups=(qt6)
_pkgfn=${pkgname/6-/}-everywhere-src-$_qtver
source=(https://download.qt.io/official_releases/qt/${pkgver%.*}/$_qtver/submodules/$_pkgfn.tar.xz
        qt3d-la64.patch)
sha256sums=('74395b686f680cfa302e41530ff9bbe1b7e13c1d1aa9d68aa192318ecbfd7c03'
            '3d0f784887aebda0498ad2778ed757069b334db8b8edf1b1e56a82e616972e55')

prepare() {
  patch -d $_pkgfn -p1 -i "$srcdir/qt3d-la64.patch"
}

build() {
  cmake -B build -S $_pkgfn -G Ninja \
    -DCMAKE_MESSAGE_LOG_LEVEL=STATUS
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  install -d "$pkgdir"/usr/share/licenses
  ln -s /usr/share/licenses/qt6-base "$pkgdir"/usr/share/licenses/$pkgname
}
